#include "../include/twentyEight_28.h"

int Binary_1_Count(const int n)
{
    if (0 == n)
        return -1;

    int sum = 0;
    int tmp = n;

    if (n < 0)
        tmp = -tmp;

    while (tmp > 0) {

        sum++;
        tmp = tmp & (tmp - 1);

    }

    return sum;
}


void TestFor28()
{
    int n = 0;
    cout <<"Please input your number :" << endl;
    cin >> n;

    int sum = Binary_1_Count(n);

    if (sum > 0)
        cout << "There are " << sum << " bits of 1 in the number " << n << endl;
}
